<?php

namespace Data;

class UserMaster extends Base {

	public function saveUserMaster($userId, $nickname, $sex, $experience, $dogNumber, $profession, $birthday, $desc) {
		$condition = array(
			'UserId' => $userId,
		);
		$data = array(
			'UserId' => $userId,
			'Nickname' => $nickname,
			'Sex' => $sex,
			'Experience' => $experience,
			'DogNumber' => $dogNumber,
			'Profession' => $profession,
			'Birthday' => $birthday,
			'Desc' => $desc,
		);
		if ($this->select('MasterId')->where($condition)->findOne()) {
			$data['UpdateTime'] = time();
			$this->where($condition)->update($data);
		} else {
			$data['CreateTime'] = time();
			$data['UpdateTime'] = time();
			$this->insert($data);
		}
	}

	public function getUserMasterInfoByUserId($userId) {
		$condition = array(
			'UserId' => $userId,
		);
		return $this->where($condition)->findOne();
	}

}